package com.meida.module.bus.provider.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.meida.common.mybatis.model.*;

import java.util.Map;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RestController;
import com.meida.common.springmvc.base.BaseController;
import com.meida.module.bus.client.entity.BusReport;
import com.meida.module.bus.provider.service.BusReportService;
import org.springframework.web.multipart.MultipartFile;


/**
 * 月报控制器
 *
 * @author flyme
 * @date 2020-11-02
 */
@RestController
@RequestMapping("/bus/report/")
public class BusReportController extends BaseController<BusReportService, BusReport> {

    @ApiOperation(value = "月报-分页列表", notes = "月报分页列表")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map params) {
        params.put("handlerName", "busReportPageListHandler");
        return bizService.pageList(params);
    }

    @ApiOperation(value = "月报-分页列表", notes = "月报分页列表")
    @GetMapping(value = "common/page")
    public ResultBody pageList1(@RequestParam(required = false) Map params) {
        params.put("handlerName", "busReportPageListHandler");
        return bizService.pageList(params);
    }

    @ApiOperation(value = "月报-列表", notes = "月报列表")
    @GetMapping(value = "list")
    public ResultBody list(@RequestParam(required = false) Map params) {
        return bizService.listEntityMap(params);
    }

    @ApiOperation(value = "月报-添加", notes = "添加月报")
    @PostMapping(value = "save")
    public ResultBody save(@RequestParam(required = false) Map params) {
        return bizService.add(params);
    }

    @ApiOperation(value = "月报-更新", notes = "更新月报")
    @PostMapping(value = "update")
    public ResultBody update(@RequestParam(required = false) Map params) {
        return bizService.edit(params);
    }

    @ApiOperation(value = "月报-删除", notes = "删除月报")
    @PostMapping(value = "remove")
    public ResultBody remove(@RequestParam(required = false) Map params) {
        return bizService.delete(params);
    }


    @ApiOperation(value = "月报-详情", notes = "月报详情")
    @GetMapping(value = "get")
    public ResultBody get(@RequestParam(required = false) Map params) {
        return bizService.get(params);
    }

    /**
     * 导出月报统计
     *
     * @param params
     * @param request
     * @param response
     */
    @PostMapping(value = "export")
    public void export(@RequestParam(required = false) Map params, HttpServletRequest request, HttpServletResponse response) {
        bizService.export(params, request, response, "月报统计", "月报统计表");
    }

    /**
     * 导入月报
     *
     * @param params
     */
    @ApiOperation(value = "导入月报", notes = "导入月报")
    @PostMapping(value = "importBusReport")
    public ResultBody importBusReport(@RequestParam(required = false) Map params, @RequestParam("file") MultipartFile file) throws Exception {
        ResultBody resultBody = bizService.importBusReport(file, params);
        return resultBody;
    }

    @ApiOperation(value = "获取未同步数据", notes = "获取未同步数据")
    @PostMapping(value = "getPreViewData")
    public ResultBody getPreViewData(@RequestParam(required = false) Map params) {
        return bizService.getPreViewData(params);
    }


    /**
     * 月报下达提交 接口
     * @param params
     * @return
     * @throws Exception
     */
    @PostMapping(value = "syncData")
    public ResultBody syncData(@RequestParam(required = false) Map params) throws Exception {
        return bizService.syncData(params);
    }
}
